﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LongestDesc.Question;

namespace LongestDesc.Answer
{
    class Albin: ILongestDesc
    {
        public int GetLongestDesc(int[] iarr)
        {
            Stack<int>[] st = new Stack<int>[20];
            int length = 0; ;
            for (int i = 0; i < iarr.Length; i++)
            {
                st[i] = new Stack<int>();
                for (int m = 0; m <= i; m++)
                {
                    if (st[m].Count > 0)
                    {
                        if (st[m].Peek() >= iarr[i])
                        {
                            st[m].Push(iarr[i]);
                        }
                    }
                    else
                    {
                        st[m].Push(iarr[i]);
                    }
                    if (length < st[m].Count)
                    {
                        length = st[m].Count;
                    }
                }
            }
            return length;
        }
    }
}
